/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: app2022 - Ex1
 * <p>Powered by webrx On 2022-02-07 16:31:01
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static void main(String[] args) {
        var t = new Ex1();
        new Thread(t::m1, "T1").start();
        //new Thread(t::m2, "T2").start();
    }

    /* Ex1.class 是锁 */
    synchronized void m1() {
        String tn = Thread.currentThread().getName();
        System.out.println(tn + "启动");
        m2();
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(tn + "线程结束....");
    }

    synchronized void m2() {
        String tn = Thread.currentThread().getName();
        System.out.println(tn + "启动");
        System.out.println("m2()...");
        System.out.printf("%s结束%n", tn);
    }
}
